package com.ingrid.android;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class ConteudoActivity extends Activity implements OnClickListener {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_list_conteudo_rss);

		Button btRssBrasil = (Button) findViewById(R.id.btRssBrasil);
		Button btRssPernambuco = (Button) findViewById(R.id.btRssPernambuco);
		Button btRssPolitica = (Button) findViewById(R.id.btRssPolitica);
		Button btRssTurismo = (Button) findViewById(R.id.btRssTurismo);
		Button btRssTecnologia = (Button) findViewById(R.id.btRssTecnologia);

		btRssBrasil.setOnClickListener(this);
		btRssPernambuco.setOnClickListener(this);
		btRssPolitica.setOnClickListener(this);
		btRssTurismo.setOnClickListener(this);
		btRssTecnologia.setOnClickListener(this);
	}

	@Override
	public void onClick(View source) {
		int sourceId = source.getId();
		String rssURL = null;

		switch (sourceId) {
		case R.id.btRssBrasil:
			rssURL = "http://g1.globo.com/dynamo/brasil/rss2.xml";
			break;
		case R.id.btRssPernambuco:
			rssURL = "http://g1.globo.com/dynamo/pernambuco/rss2.xml";
			break;
		case R.id.btRssPolitica:
			rssURL = "http://g1.globo.com/dynamo/politica/mensalao/rss2.xml";
			break;
		case R.id.btRssTurismo:
			rssURL = "http://g1.globo.com/dynamo/turismo-e-viagem/rss2.xml";
			break;
		case R.id.btRssTecnologia:
			rssURL = "http://g1.globo.com/dynamo/tecnologia/rss2.xml";
			break;
		}

		if (rssURL != null) {
			Intent intent = new Intent(this, ShowRssActivity.class);
			intent.putExtra(ShowRssActivity.EXTRA_RSS_URL, rssURL);
			this.startActivity(intent);
		}

	}

}
